﻿
using Azure;
using Azure.AI.Inference;

//https://models.inference.ai.azure.com ; https://models.github.ai/inference

//创建一个api结点
Uri endpoint = new Uri("https://models.github.ai/inference");

//创建一个Azure凭证
AzureKeyCredential azureKeyCredential = new AzureKeyCredential("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");

//创建对话客户端对象
ChatCompletionsClient chatClient=new ChatCompletionsClient(endpoint, azureKeyCredential);
var model = "deepseek/DeepSeek-V3-0324";//"microsoft/MAI-DS-R1";//"deepseek/DeepSeek-V3-0324"
//创建客户端配置

var requestOptions = new ChatCompletionsOptions()
{
    Temperature=0.8f,
    MaxTokens = 2041,
    Model = model
};

//添加对话信息

while (true)
{
    Console.Write("请输入你的问题：");
    string msg = Console.ReadLine()!;
    requestOptions.Messages.Add(new ChatRequestUserMessage(msg));
    //发送对话请求
    var result = await chatClient.CompleteAsync(requestOptions);

    //将ai返回的消息添加到消息上下文中

    requestOptions.Messages.Add(new ChatRequestAssistantMessage(result.Value.Content));
    Console.WriteLine(result.Value.Content); 
}
Console.ReadKey();